Jenkins Integration Guide
This guide outlines the steps to integrate your project with Jenkins using pipelines. Jenkins pipelines automate the build, test, and deployment process, providing a structured way to manage your project's lifecycle.
Prerequisites
- A Jenkins instance set up and running.
- Access to your project's source code repository.
- The following tools installed on your Jenkins server:
- jq: A lightweight and flexible command-line JSON processor. You can install it by following the instructions at jq installation guide.
- curl: A command-line tool to transfer data to or from a server using various protocols. You can install it by following the instructions at curl download page.
- Configure the necessary environment variables such as path in Jenkins settings that your pipeline might need during the build process.
Steps
Step 1: Setting Up a New Pipeline
- Open the **Jenkins Admin ** dashboard.
- Click on create a new item.
- Choose pipeline as the project type and give it a meaningful name.
- Trigger the job to ensure that the pipeline folder is created.
Step 2: Configuring Pipeline Options
-
After creating the pipeline, navigate to its configuration.
-
Without Source Code Management
- Select definition as pipeline script.
- Copy the sample Jenkinsfile to script editor.
-
With Source Code Management
- Select definition as pipeline script from SCM.
- Select SCM as git.
- Enter Repository URL and Credentials in Repositories section.
- Make sure to have Jenkinsfile in the root directory of the repository.
Step 3: Handling the Execution Script
-
Update api key in environement section of Jenkinsfile script with
sample_api_integration_key
-
Download the execute.sh file and place it in the appropriate location:
- For projects without Source Code Management, place it in
pathToJenkinsWorkspace/pipelineName
. - For projects with Source Code Management, place it in the repository.
- For projects without Source Code Management, place it in
-
Grant execute permission to the execute.sh file.
-
Update first step in
Run Test Script
stage of Jenkinsfile assh 'pathToJenkinsWorkspace/pipelineName/execute.sh -t ${API_KEY}'
where pathToJenkinsWorkspace is jenkins workspace directory and pipelineName is the name of the pipeline. e.gsh '/home/root/.jenkins/workspace/test_pipeline/execute.sh -t ${API_KEY}'
-
Update the placeholder
PLACE_YOUR_CURL_COMMAND_HERE
with your actual curl command:curl --location false/v2/apikeyexecution \ --header "Content-Type: application/json" \ --header "api-key: sample_api_integration_key" \ --data '{ "projectId": "PROJECT_ID", "organizationId": "ORGANIZATION_ID", "scenarioIds": ["SCENARIO_ID1", "SCENARIO_ID2"], "config": { "browser": { "id": "chrome", "label": "Chrome" }, "environmentId": "ENV_ID", "os": { "id": "ubuntu", "label": "Ubuntu" }, "resolution": { "id": "1", "label": "Ultra-Wide 4K (3840×2160)" } } }'
in execute.sh file on line no. 71.
Step 4: Finalizing Configuration
- Save the pipeline configuration.
- Trigger a build by clicking on Build Now.